<%@ page contentType="text/html; charset=utf-8"%>
<%@ page import="cn.agiledata.bank.common.util.Constant"%>
<%@ page import="cn.agiledata.bank.account.service.AccountSummary"%>
<%@ page import="java.util.List"%>
<%@ page import="cn.agiledata.bank.hibernateBean.SubAccount"%>
<%@ taglib uri="/WEB-INF/conf/tld/struts-bean.tld" prefix="bean"%>
<%@ taglib uri="/WEB-INF/conf/tld/struts-logic.tld" prefix="logic"%>
<%@ taglib prefix="ad" uri="agiledata"%>
<%//String code = ImageUtil.getRandomNumber(4) ;
			//session.setAttribute(Constant.SESSION_VERIFY_CODE, code) ;
			String path = request.getContextPath();
			AccountSummary user = (AccountSummary) session
					.getAttribute(Constant.SESSION_ACCOUNT_SUMMARY);
		
			String str = request.getParameter("dis");
			
			if (user == null) {

			%>
  
<%} 

			%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
	<head>
		<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
		<link href="../../css/style1.css" rel="stylesheet" type="text/css">
		<link href="../../css/style.css" rel="stylesheet" type="text/css">
		<link href="<%=path%>/css/newstyle.css" rel="stylesheet" type="text/css" />
<link href="<%=path%>/css/common.css" rel="stylesheet" type="text/css" />
	</head>

	<body>
		<form action="toAddSubAccount.do?next=toAddSubAccount" method="post">
		
  <div align="center"><br>
    <table width="732" border="0" cellpadding="0" cellspacing="3" bgcolor="0EA2D6">
      <tr> 
        <td  bgcolor="#FFFFFF"><table width="100%" border="0" cellspacing="0" cellpadding="0">
            <tr> 
              <td height="25" align="center" background="<%=path%>/images/new/blue_pic_01.gif"><strong><font color="#FFFFFF" style="font-size:12px">查看账户信息</font></strong></td>
            </tr>
			<logic:notEqual name="delError" value=""> 
			 <script>
				<!--//
				alert('<%=request.getSession().getAttribute("delError")%>!') ;
				//-->
			</script>          
            <%request.getSession().removeAttribute("delError");%>
			</logic:notEqual>	
			
          </table>
          <table width="100%" border="0" cellspacing="0" cellpadding="0">
            <tr> 
              <td height="8" ></td>
            </tr>
          </table>
          <table width="100%" border="0" cellspacing="0" cellpadding="8">
            <tr> 
              <td><table width="100%" border="0" cellpadding="0" cellspacing="0">
                  <tr> 
                    <td><table  width="100%" align="center" cellpadding="3" cellspacing="1" class="form">
              <tr> 
                <th width="50%" bgcolor="F0FAFD">名称</th>
                <td width="50%" bgcolor="F0FAFD"><span><bean:write name="accountinfo" property="name"/></span></td>
              </tr>
              <tr> 
                <th>Email</th>
                <td><bean:write name="accountinfo" property="email"/></td>
              </tr>
              <tr> 
                <th bgcolor="F0FAFD">手机</th>
                <td bgcolor="F0FAFD"><bean:write name="accountinfo" property="mobile"/></td>
              </tr>
              <tr> 
                <th bgcolor="F0FAFD">客户类型</th>
                <td bgcolor="F0FAFD"><ad:write typeid="ACCOUNT_TYPE" name="accountinfo" property="accountType" /></td>
              </tr>
              <tr> 
                <th bgcolor="F0FAFD">状态</th>
                <td bgcolor="F0FAFD"><ad:write typeid="CUSTOMER_STATUS" name="accountinfo" property="status" /></td>
              </tr>
              <tr> 
                <th bgcolor="F0FAFD">联系地址</th>
                <td bgcolor="F0FAFD"><bean:write name="accountinfo" property="addr"/></td>
              </tr>
            </table> 
                      <table width="100%" border="0" align="center" cellpadding="0" cellspacing="1">
                        <tbody>
                          <tr> 
                            <td height="30" class="dyg1"> 
                              <div align="center"> 
                                默认 </div></td>
                            <td height="30" class="dyg1"> 
                              <div align="center"> 
                                子账户代码 </div></td>
                            <td height="30" class="dyg1"> 
                              <div align="center"> 
                                子账户名称 </div></td>
                            <td height="30" class="dyg1"> 
                              <div align="center"> 
                                Wap账户 </div></td>
                                 <td height="30" class="dyg1"> 
                              <div align="center"> 
                                IVR账户 </div></td>
                            <td height="30" class="dyg1"> 
                              <div align="center"> 
                                编辑 </div></td>
                            <td height="30" class="dyg1"> 
                              <div align="center"> 
                                删除 </div></td>
                          </tr>
                          <%List subList = user.getSubAccountList();

			for (int i = 0; i < subList.size(); i++) {
				SubAccount sub = (SubAccount) subList.get(i);
				long defaultSubId = user.getDefaultSubAccountId();

				long id = sub.getId().longValue();
				String number = sub.getAccountId() == null ? "" : sub
						.getAccountId();
				String name = sub.getAccountName() == null ? "" : sub
						.getAccountName();
				String remark = sub.getRemark() == null ? "" : sub.getRemark();
				boolean isBalanceZero = (sub.getAccountBalance().getBalance().doubleValue() == 0.00);
				boolean isDefault = (defaultSubId == id);
				boolean isWap = false;				
				String isWap2 = "";
				boolean isIVR = false;
				String isIVR2 = "";
				isIVR = sub.getIvrFlag().equals("Y");
				if(isIVR){isIVR2 = "是";}else{isIVR2 = "否";}
				if(sub.getDetailFlag() != null) {
					isWap = sub.getDetailFlag().equals("Y");
				}
				if(isWap = sub.getDetailFlag().equals("Y")){
					isWap2 = "是";
				}else{
					isWap2 = "否";
				}

				%>
                          <tr> 
                            <td height="18" class="<%=i%2==0?"dyg3":"dyg2"%>"> 
                              <div align="center"> 
                                <input <% if (isDefault) { %> checked="checked" <% } else {%> onclick="javascript:if(confirm('您真的要更改默认子账户吗？')){ location.href='changeDefaultSubAccount.do?key=<%=id%>';}" <% } %> readonly="readonly" type="radio" />
                              </div></td>
                            <td height="18" class="<%=i%2==0?"dyg3":"dyg2"%>"> 
                              <div align="center"> 
                                <%=number%>
                              </div></td>
                            <td height="18" class="<%=i%2==0?"dyg3":"dyg2"%>"> 
                              <div align="center"> 
                                <%=name%>
                              </div></td>
                            <td height="18" class="<%=i%2==0?"dyg3":"dyg2"%>"> 
                              <div align="center"> 
                                <%=isWap2%>
                              </div></td>
                               <td height="18" class="<%=i%2==0?"dyg3":"dyg2"%>"> 
                              <div align="center"> 
                                <%=isIVR2%>
                              </div></td>
                            <td height="18" class="<%=i%2==0?"dyg3":"dyg2"%>"> 
                              <div align="center"> <!-- <img height="16" src="<%=path%>/images/edit.gif" width="18" border="0" style="cursor:pointer;" onclick="location.href='toModifySubAccount.do?key=<%=id%>';" />	-->
                              </div></td>
                            <td height="18" class="<%=i%2==0?"dyg3":"dyg2"%>"> 
                              <div align="center"> 
                                <%if (!isDefault && isBalanceZero) {
					%>
                                <%if(!isWap) {%>
                                <img height="16" src="<%=path%>/images/new2_06_2.gif" width="15" border="0" style="cursor:pointer;" onclick="if(confirm('您确定要删除该子账户吗？')){ location.href='deleteSubAccount.do?key=<%=id%>';}" /> 
                                <%} else {%>
                                <img height="16" src="<%=path%>/images/new2_06_2.gif" width="15" border="0" style="cursor:pointer;" onclick="if(confirm('您的wap账户将变更为默认子账户,确定吗?')) {if(confirm('您确定要删除该子账户吗？')){ location.href='deleteSubAccount.do?key=<%=id%>';}}" /> 
                                <%}%>
                                <%} else {%>
                                <img height="16" src="<%=path%>/images/new2_06_2.gif" width="15" border="0" title="默认子账户或者余额不为零的子账户不允许删除" /> 
                                <%}%>
                              </div></td>
                          </tr>
                          <%}%>
                        </tbody>
                      </table></td>
                  </tr>
                  <tr> 
                    <td height="35"> <div align="center"> 
                      <%if (str!=null && str.equals("true")){ %>  
						<input onclick="location.href='<%=path%>/route.do?modual=manage$query'" type="button" value="返 回" name="back" class="button_3"/>
					 <%}else{ %>
						 <!-- <input type="button" value="添加子账户" name="Submit" class="button_3" onclick="document.forms[0].submit();"/>-->
                        <input onclick="location.href='<%=path%>/page/myspace/accountInfo.do'" type="button" value="返 回" name="back" class="button_3"/>
 		              <%} %>    
                      </div></td>
                  </tr>
                </table>
            
              </td>
            </tr>
          </table></td>
      </tr>
    </table>
			</div>
		</form>
	</body>
</html>
